Skip to content

Fix magic_enum discovery for build-dir CDT_ROOT#44

Merged
heifner merged 3 commits intomasterfrom
fix/magic-enum-vcpkg-discovery
Mar 30, 2026
Merged

Fix magic_enum discovery for build-dir CDT_ROOT#44
heifner merged 3 commits intomasterfrom
fix/magic-enum-vcpkg-discovery

Conversation

@heifner
Copy link
Copy Markdown
Contributor

@heifner heifner commented Mar 26, 2026

Summary

  • When using a CDT build directory as CDT_ROOT (not an installed prefix), magic_enum headers are in vcpkg_installed/ rather than include/, causing 'magic_enum/magic_enum.hpp' file not found
  • Add vcpkg fallback path in find_cdt_magic_enum using VCPKG_INSTALLED_DIR and VCPKG_TARGET_TRIPLET variables (platform-independent, no hardcoded triplet)
  • Uncomment the CDT_CONTRACT_INCLUDE_PATH search path that was previously disabled
  • Add diagnostic message when contract include path is active

When using a CDT build directory as CDT_ROOT (instead of a proper
install prefix), magic_enum headers are not in CDT_ROOT/include but
in the vcpkg_installed directory. Add vcpkg path as a fallback in
find_cdt_magic_enum using VCPKG_INSTALLED_DIR and VCPKG_TARGET_TRIPLET.

Also uncomment the CDT_CONTRACT_INCLUDE_PATH search path and add a
diagnostic message when the contract include path is active.
heifner added a commit to Wire-Network/wire-sysio that referenced this pull request Mar 26, 2026
Set CDT_CONTRACT_INCLUDE_PATH from vcpkg include directory and forward
it to the CDT toolchain so contract builds can locate vcpkg-provided
headers (e.g. magic_enum) when using a CDT build directory as CDT_ROOT.

Also reformats CDT_CMAKE_ARGS for readability.

Companion to Wire-Network/wire-cdt#44.
@heifner heifner requested a review from jglanz March 26, 2026 16:14
Copy link
Copy Markdown
Collaborator

@jglanz jglanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, but give the inline comment a crack before merging

# set_target_properties(magic_enum::magic_enum PROPERTIES
# INTERFACE_INCLUDE_DIRECTORIES "${CDT_CONTRACT_INCLUDE_PATH}"
# )
elseif(IS_DIRECTORY "${CDT_CONTRACT_INCLUDE_PATH}/magic_enum")
Copy link
Copy Markdown
Collaborator

@jglanz jglanz Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One note CDT_CONTRACT_INCLUDE_PATH could be a semicolon delimited list; I'd create a nested macro invoked as find_in_cdt_contract_paths(_matched_include_path MATCH magic_enum [DIRECTORY|FILE] [MATCH_VAR_FULL _full_matched_path_with_suffix])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heifner added 2 commits March 30, 2026 07:36
Add find_in_cdt_contract_paths() helper macro that iterates over
CDT_CONTRACT_INCLUDE_PATH entries to find matching directories or
files, instead of treating it as a single path.
The tools sub-build could not find vcpkg packages like protobuf
because CMAKE_PREFIX_PATH was not forwarded. Also reformats the
CMAKE_ARGS to one-per-line for readability.
@heifner heifner merged commit 533507a into master Mar 30, 2026
4 checks passed
@heifner heifner deleted the fix/magic-enum-vcpkg-discovery branch March 30, 2026 15:54
Copy link
Copy Markdown
Collaborator

@jglanz jglanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heifner one more exit

-DCMAKE_PREFIX_PATH=${_vcpkg_share}/..
-DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR}
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DVCPKG_INSTALLED_DIR=${CMAKE_BINARY_DIR}/vcpkg_installed
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the VCPKG variable instead of vpkg_installed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants